﻿package  {
	import flash.display.MovieClip;
	import flash.geom.Point;
	
	public class Gun extends Unit{
		var updateCounter:Number=0;
		var fireRate:Number=10;
		var firing:Boolean=false;
		public function Gun(map:Map,canvas:MovieClip,location:Point) {
			super(map,canvas,location);
			updateCounter=0;
		}
		public override function update(){
			updateCounter++;
			if(updateCounter==fireRate){
				fire();
				updateCounter=0;
			}
		}
		public function fire(){
			var bullet:Bullet=new Bullet(map,canvas,location);
			bullet.setTarget(new Point(mouseX+240,mouseY+160));
			canvas.addChild(bullet);
		}

	}
	
}
